const query = require('../config/sql');

module.exports = async (id) => {
    const sql1 = `select * from messagelist where receiverId="${id}" and cache="1" order by time asc;`
    const sql2 = `update  messagelist set cache="0" where receiverId="${id}";`
    let result = []
    await query(sql1).then(async res => {
        if (res) {
            result = res
            await query(sql2)
        }
    })
    return result
}